import request from '@/utils/request'
import { Punishment, PaginationParams, PaginationResult } from '@/types'

/**
 * 获取惩罚列表
 */
export function getPunishmentList(params: PaginationParams & { studentId?: number }) {
  return request<PaginationResult<Punishment>>({
    url: '/punishments',
    method: 'get',
    params
  })
}

/**
 * 获取学生的所有惩罚
 */
export function getStudentPunishments(studentId: number) {
  return request<Punishment[]>({
    url: `/students/${studentId}/punishments`,
    method: 'get'
  })
}

/**
 * 创建惩罚记录
 */
export function createPunishment(data: Partial<Punishment>) {
  return request<Punishment>({
    url: '/punishments',
    method: 'post',
    data
  })
}

/**
 * 更新惩罚
 */
export function updatePunishment(id: number, data: Partial<Punishment>) {
  return request<Punishment>({
    url: `/punishments/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除惩罚
 */
export function deletePunishment(id: number) {
  return request({
    url: `/punishments/${id}`,
    method: 'delete'
  })
}

